import os
from IPython.display import display, HTML, IFrame
NBdir='C:\\Users\\Gamaliel\\Documents\\G\\ADD\\IBM_DS\\Visualization\\'
os.chdir(NBdir)
ModuleFolder='C:\\Users\\Gamaliel\\Documents\\G\\ADD\\IBM_DS\\Visualization\\M01\\IBMs\\HTML\\'
os.chdir(ModuleFolder)
for file in os.listdir(ModuleFolder):
    #if file.lower().endswith('HTMLs.html'):
        #continue
    if file.lower().endswith('.html'):
        link=file
        #print(link)  
        display(HTML(ModuleFolder+link))
    elif file.lower().endswith('.htm'):
        link=file
        #print(link)  
        display(HTML(ModuleFolder+link))
    else:
        continue
    
cognitiveclass.ai logo

Data Visualization with Python

Cheat Sheet : Data Preprocessing Tasks in Pandas

Task
Syntax
Description
Example
Load CSV data pd.read_csv('filename.csv') Read data from a CSV file into a Pandas DataFrame df_can=pd.read_csv('data.csv')
Handling Missing Values df.dropna() Drop rows with missing values df_can.dropna()
df.fillna(value) Fill missing values with a specified value df_can.fillna(0)
Removing Duplicates df.drop_duplicates() Remove duplicate rows df_can.drop_duplicates()
Renaming Columns df.rename(columns={'old_name': 'new_name'}) Rename one or more columns df_can.rename(columns={'Age': 'Years'})
Selecting Columns df['column_name'] or df.column_name Select a single column df_can.Age or df_can['Age]'
df[['col1', 'col2']] Select multiple columns df_can[['Name', 'Age']]
Filtering Rows df[df['column'] > value] Filter rows based on a condition df_can[df_can['Age'] > 30]
Applying Functions to Columns df['column'].apply(function_name) Apply a function to transform values in a column df_can['Age'].apply(lambda x: x + 1)
Creating New Columns df['new_column'] = expression Create a new column with values derived from existing ones df_can['Total'] = df_can['Quantity'] * df_can['Price']
Grouping and Aggregating df.groupby('column').agg({'col1': 'sum', 'col2': 'mean'}) Group rows by a column and apply aggregate functions df_can.groupby('Category').agg({'Total': 'mean'})
Sorting Rows df.sort_values('column', ascending=True/False) Sort rows based on a column df_can.sort_values('Date', ascending=True)
Displaying First n Rows df.head(n) Show the first n rows of the DataFrame df_can.head(3)
Displaying Last n Rows df.tail(n) Show the last n rows of the DataFrame df_can.tail(3)
Checking for Null Values df.isnull() Check for null values in the DataFrame df_can.isnull()
Selecting Rows by Index df.iloc[index] Select rows based on integer index df_can.iloc[3]
df.iloc[start:end] Select rows in a specified range df_can.iloc[2:5]
Selecting Rows by Label df.loc[label] Select rows based on label/index name df_can.loc['Label']
df.loc[start:end] Select rows in a specified label/index range df_can.loc['Age':'Quantity']
Summary Statistics df.describe() Generates descriptive statistics for numerical columns df_can.describe()

Cheat Sheet : Plot Libraries

Library Main Purpose Key Features Programming Language Level of Customization Dashboard Capabilities Types of Plots Possible
Matplotlib General-purpose plotting Comprehensive plot types and variety of customization options Python High Requires additional components and customization Line plots, scatter plots, bar charts, histograms, pie charts, box plots, heatmaps, etc.
Pandas Fundamentally used for data manipulation but also has plotting functionality Easy to plot directly on Panda data structures Python Medium Can be combined with web frameworks for creating dashboards Line plots, scatter plots, bar charts, histograms, pie charts, box plots, etc.
Seaborn Statistical data visualization Stylish, specialized statistical plot types Python Medium Can be combined with other libraries to display plots on dashboards Heatmaps, violin plots, scatter plots, bar plots, count plots, etc.
Plotly Interactive data visualization interactive web-based visualizations Python, R, JavaScript High Dash framework is dedicated for building interactive dashboards Line plots, scatter plots, bar charts, pie charts, 3D plots, choropleth maps, etc.
Folium Geospatial data visualization Interactive, customizable maps Python Medium For incorporating maps into dashboards, it can be integrated with other frameworks/libraries Choropleth maps, point maps, heatmaps, etc.
PyWaffle Plotting Waffle charts Waffle charts Python Low Can be combined with other libraries to display waffle chart on dashboards Waffle charts, square pie charts, donut charts, etc.
ModuleFolder='C:\\Users\\Gamaliel\\Documents\\G\\ADD\\IBM_DS\\Visualization\\M02\\IBMs\\HTMLs\\'
os.chdir(ModuleFolder)
for file in os.listdir(ModuleFolder):
    #if file.lower().endswith('HTMLs.html'):
        #continue
    if file.lower().endswith('.html'):
        link=file
        #print(link)  
        display(HTML(ModuleFolder+link))
    elif file.lower().endswith('.htm'):
        link=file
        #print(link)  
        display(HTML(ModuleFolder+link))
    else:
        continue
    

Understanding Treemaps and Pivot Charts

Treemaps

Treemaps are a form of data visualization that displays hierarchical data using nested rectangles. Each branch of the hierarchy is given a rectangle, which is then tiled with smaller rectangles representing sub-branches. Treemaps are particularly useful for visualizing large datasets where the hierarchical structure is crucial, offering an intuitive and space-efficient way to display data.

Applications of Treemaps

Treemaps are employed across various domains due to their ability to effectively communicate complex hierarchical data. Some common applications include:

  1. Business Analytics: Visualizing the composition of sales by product categories and subcategories.
  2. Finance: Displaying the performance of stock portfolios, sectors, and industries.
  3. IT and Network Management: Representing file systems or network usage, showing the distribution of files and folders.
  4. Bioinformatics: Displaying hierarchical biological data, such as taxonomies or genomic structures.
  5. Website Analytics: Showing the structure of website traffic, with rectangles representing web pages and their size indicating the volume of visits.

Importance in Data Visualization

Treemaps are important in data visualization for several reasons:

  • Space Efficiency: Treemaps make efficient use of space, allowing large datasets to be visualized within a limited area.
  • Hierarchy Representation: They provide a clear representation of hierarchical data, showing both the structure and the quantitative relationship between elements.
  • Comparative Analysis: Treemaps make it easy to compare the sizes of different elements at various levels of the hierarchy.
  • Immediate Insight: The color and size of the rectangles can quickly convey important information, making it easier for users to spot patterns and outliers.

Syntax for Generating Treemap

We can generate Treemaps using the Plotly library in Python.

  1. Install Required Libraries:

    1. 1
    1. pip install plotly pandas
  2. Import Libraries:

    1. 1
    2. 2
    1. import pandas as pd
    2. import plotly.express as px
  3. Load Data:

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    1. # Replace with your actual dataset or data source
    2. data = {
    3. 'Category': ['Category 1', 'Category 1', 'Category 2', 'Category 2', 'Category 3'],
    4. 'Subcategory': ['Subcategory 1A', 'Subcategory 1B', 'Subcategory 2A', 'Subcategory 2B', 'Subcategory 3A'],
    5. 'Value': [10, 20, 30, 40, 50]
    6. }
    7. df = pd.DataFrame(data)
  4. Create Treemap:

    1. 1
    2. 2
    3. 3
    4. 4
    1. fig = px.treemap(df,
    2. path=['Category', 'Subcategory'], # Define hierarchical structure
    3. values='Value', # Size of each rectangle
    4. title='Treemap Example') # Title of the treemap
  5. Show Treemap:

    1. 1
    1. fig.show()

Practical Example: Visualizing Sales Data

Let's use Plotly Express to visualize the sales data example.

Sample Data

Assume we have the following hierarchical sales data:

  • Electronics
    • Laptops: 120,000
    • Smartphones: 80,000
    • Tablets: 30,000
  • Furniture
    • Chairs: 50,000
    • Tables: 40,000
    • Sofas: 20,000
  • Clothing
    • Men: 70,000
    • Women: 90,000
    • Kids: 40,000

Code to Generate Treemap

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  1. import plotly.express as px
  2. import pandas as pd
  3. # Sales data
  4. data = {
  5. 'Category': ['Electronics', 'Electronics', 'Electronics',
  6. 'Furniture', 'Furniture', 'Furniture',
  7. 'Clothing', 'Clothing', 'Clothing'],
  8. 'Subcategory': ['Laptops', 'Smartphones', 'Tablets',
  9. 'Chairs', 'Tables', 'Sofas',
  10. 'Men', 'Women', 'Kids'],
  11. 'Sales': [120000, 80000, 30000,
  12. 50000, 40000, 20000,
  13. 70000, 90000, 40000]
  14. }
  15. df = pd.DataFrame(data)
  16. # Creating the treemap
  17. fig = px.treemap(
  18. df,
  19. path=['Category', 'Subcategory'],
  20. values='Sales',
  21. title='Sales Data Treemap'
  22. )
  23. fig.show()

Output

Conclusion

Treemaps are a powerful tool for visualizing hierarchical data, offering an efficient and intuitive way to compare elements within a hierarchy. Their applications are diverse, ranging from business analytics to bioinformatics. By following the provided code, you can generate treemaps to visualize your own hierarchical datasets, making it easier to gain insights and communicate information effectively.

Pivot Charts

Introduction

Pivot charts are a powerful tool used for data visualization and analysis. They allow users to dynamically summarize and explore large datasets, revealing insights and trends that might not be immediately obvious. Pivot charts are widely used in business intelligence, finance, marketing, and various other fields where data analysis is crucial.

Applications of Pivot Charts

  1. Business Intelligence: Pivot charts help in summarizing complex business data, making it easier for stakeholders to make informed decisions.
  2. Finance: Analysts use pivot charts to visualize financial data, track performance metrics, and forecast trends.
  3. Marketing: Marketers leverage pivot charts to analyze campaign performance, customer demographics, and sales trends.
  4. Operations: Operational managers use pivot charts to monitor supply chain performance, inventory levels, and process efficiencies.
  5. Healthcare: Pivot charts assist in visualizing patient data, treatment outcomes, and operational efficiency in healthcare settings.

Importance in Data Visualization

  • Data Summarization: Quickly summarizes large datasets, making them more manageable and understandable.
  • Dynamic Analysis: Allows users to interactively explore data by filtering, sorting, and drilling down into specific areas of interest.
  • Trend Identification: Helps in identifying patterns and trends that can inform strategic decision-making.
  • Efficiency: Enhances productivity by providing a quick way to visualize and interpret data without extensive manual processing.
  • Presentation: Facilitates the creation of professional and informative reports that can be easily shared with stakeholders.

Sample

Consider a sample data given below. This data is assumed to have a 100 entries.

Item Category Subcategory Value
P B Y 62
S C Y 86
Q A X 98
P A Y 45
S C X 35
P B X 37
R B Y 26
S A Y 33
Q A Y 43
P A Y 15

Treating the column Item as the index, i.e., the row component, and Category and Subcategory as columns, i.e., the column components, with Value acting as the aggregated entity, the pivot graph can be created, summarizing the data as shown below.

Syntax for Generating Pivot Charts in Python

Python, with libraries such as Pandas and Matplotlib, provides robust capabilities for creating pivot charts. Below is a step-by-step guide to generating pivot charts using Python.

  1. Install Required Libraries:

    1. 1
    1. pip install pandas matplotlib
  2. Import Libraries:

    1. 1
    2. 2
    1. import pandas as pd
    2. import matplotlib.pyplot as plt
  3. Load Data:

    1. 1
    2. 2
    1. # Load data into a pandas DataFrame
    2. data = pd.read_csv('your_dataset.csv')
  4. Create a Pivot Table:

    1. 1
    2. 2
    3. 3
    1. pivot_table = data.pivot_table(values='ValueColumn', index='RowIndexColumn', columns='ColumnIndexColumn', aggfunc='sum')
  5. Generate Pivot Chart:

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    1. pivot_table.plot(kind='bar')
    2. plt.title('Pivot Chart Title')
    3. plt.xlabel('X-axis Label')
    4. plt.ylabel('Y-axis Label')
    5. plt.show()

Practical Example

Let's walk through a practical example using a sample dataset. We'll create a pivot chart to visualize sales data.

  1. Sample Data:
    For this example, we are creating dummy data on sales of IT products across different quarters. The data generated would be of the following form.

    S. No. Date Category Subcategory Sales
    0 Q1 Peripherals Accessories 2092
    1 Q1 Software Accessories 4695
    2 Q1 Software Components 3106
    3 Q1 Desktops Accessories 3527
    4 Q1 Laptops Software Suites 1182
    2395 Q4 Desktops Accessories 2557
    2396 Q4 Software Accessories 2626
    2397 Q4 Desktops Components 2427
    2398 Q4 Software Components 1768
    2399 Q4 Peripherals Components 1714
    Click here to get the code

    This data was generated using the code below.

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    1. import pandas as pd
    2. import numpy as np
    3. import matplotlib.pyplot as plt
    4. # Define the parameters
    5. num_quarters = 4
    6. num_categories = 4
    7. num_subcategories = 3
    8. num_samples = num_quarters * num_categories * num_subcategories*50
    9. # Generate sample sales data
    10. np.random.seed(40)
    11. # Creating sample data
    12. dates = np.repeat(['Q1','Q2','Q3','Q4'], 50*num_categories * num_subcategories)
    13. categories = np.tile(np.random.choice(['Laptops', 'Desktops', 'Peripherals', 'Software'], size=num_quarters*50), num_categories * num_subcategories)
    14. subcategories = np.tile(np.random.choice(['Accessories', 'Components', 'Software Suites'], size=num_quarters*50), num_categories * num_subcategories)
    15. sales_values = np.random.randint(1000, 5000, size=num_samples)
    16. # Create DataFrame
    17. df = pd.DataFrame({
    18. 'Date': dates,
    19. 'Category': categories,
    20. 'Subcategory': subcategories,
    21. 'Sales': sales_values
    22. })
  2. Create a Pivot Table:

    1. 1
    2. 2
    3. 3
    4. 4
    1. # Create pivot table
    2. pivot_table = df.pivot_table(index='Date', columns=['Category','Subcategory'], values='Sales', aggfunc=np.sum)
  3. Generate Pivot Chart:

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    1. # Plotting a pivot chart
    2. pivot_table.plot(kind='bar', figsize=(14, 8))
    3. plt.title('Sales Summary of IT Products by Category and Subcategory')
    4. plt.xlabel('Quarters')
    5. plt.ylabel('Total Sales')
    6. plt.grid(False)
    7. plt.legend(title=('Category', 'Subcategory'), bbox_to_anchor=(1.05, 1), loc='upper left')
    8. plt.tight_layout()
    9. plt.show()

Output

Conclusion

Pivot charts are an indispensable tool for data analysis, providing a dynamic and intuitive way to summarize and visualize data. By leveraging libraries like Pandas and Matplotlib in Python, you can easily create pivot charts to uncover insights and make data-driven decisions. Whether for business intelligence, finance, marketing, or any other field, pivot charts enhance the ability to analyze and interpret data effectively.


cognitiveclass.ai logo

Data Visualization with Python

Cheat Sheet : Plotting with Matplotlib using Pandas

Plot Type
Description
Pandas Function
Example
Visual
Line Plot Shows trends and changes over time DataFrame.plot.line()
DataFrame.plot(kind = ‘line’)
df.plot(x=’year’, y=’sales’, kind=’line’)
Area Plot Displays data series as filled areas, showing the relationship between them DataFrame.plot.area()
DataFrame.plot(kind = ‘area’)
df.plot(kind='area')
Histogram Displays bars representing the data count in each interval/bin Series.plot.hist()
Series.plot(kind = ‘hist’, bins = n)
s.plot(kind='hist', bins=10)
df[‘age’].plot(kind='hist', bins=10)
Bar Chart Displays data using rectangular bars DataFrame.plot.bar()
DataFrame.plot(kind = ‘bar’)
df.plot(kind='bar')
Pie Chart Displays data as a circular plot divided into slices, representing proportions or percentages of a whole Series.plot.pie()
Series.plot(kind = ‘pie’)
DataFrame.plot.pie(y, labels)
DataFrame.plot(kind = ‘pie’)
s.plot(kind='pie’,autopct='%1.1f%%')
df.plot(x='Category',y='Percentage',kind='pie')
Box Plot Displays the distribution of a dataset along with key statistical measures DataFrame.plot.box()
DataFrame.plot(kind = ‘box’)
df_can.plot(kind='box')
Scatter Plot Uses Cartesian coordinates to display values for two variables DataFrame.plot.scatter()
DataFrame.plot(x, y, kind = ‘scatter’)
df.plot(x='Height', y='Weight', kind='scatter')

Cheat Sheet : Plotting directly with Matplotlib

Plot Type
Description
Matplotlib Function
Example
Visual
Line Plot Shows trends and changes over time plt.plot() plt.plot(x, y, color='red', linewidth=2)
Area Plot Display data series as filled areas plt.fill_between() plt.fill_between(x, y1, y2, color='blue', alpha=0.5)
Histogram Displays bars representing the data count in each interval/bin plt.hist() plt.hist(data, bins=10, color='orange', edgecolor='black')
Bar Chart Displays data using rectangular bars plt.bar() plt.bar(x, height, color='green', width=0.5)
Pie Chart Displays data as a circular plot divided into slices, representing proportions or percentages of a whole plt.pie() plt.pie(sizes, labels=labels, colors=colors, explode=explode)
Box Plot Displays the distribution of a dataset along with key statistical measures plt.boxplot() plt.boxplot(data, notch=True)
Scatter Plot Uses Cartesian coordinates to display values for two variables plt.scatter() plt.scatter(x, y, color='purple', marker='o', s=50)
Subplotting Creating multiple plots on one figure plt.subplots() fig, axes = plt.subplots(nrows=2, ncols=2)
Customization Customizing plot: adding labels, title, legend, grid Various customization plt.title('Title')
plt.xlabel('X Label')
plt.ylabel('Y Label')
plt.legend()
plt.grid(True)


Author(s)

Dr. Pooja

cognitiveclass.ai logo

Data Visualization with Python

Cheat Sheet : Maps, Waffles, WordCloud and Seaborn

Function

Description

Syntax

Example

Visual

Folium
Map Create a map object with specified center coordinates and zoom level. folium.Map(location=[lat, lon], zoom_start=n) world_map = folium.Map()

canada =folium.Map(location=[56.130, -106.35], zoom_start=4)
Marker Add a marker to the map with custom icon, popup, and tiles

Tiles as Stamen Toner
folium.Marker(location=[lat , lon ],
popup='Marker Popup',
tiles='Stamen Toner').add_to(map)
folium.Marker(location=[556.130, -106.35],
tooltip='Marker',
tiles='Stamen Toner').add_to(world_map)
Tiles as Stamen Terrain folium.Marker(location=[lat , lon ],
popup='Marker Popup',
tiles='Stamen Terrain').add_to(map)
folium.Marker(location=[556.130, -106.35],
tooltip='Marker',
tiles='Stamen Terrain').add_to(world_map)
Circle Add a circle to the map with specified radius, color, and fill opacity. folium.features.CircleMarker(location=[lat, lon],
radius=n, color='red',
fill_opacity=n).add_to(map)
folium.features.CircleMarker(location=[56.130, -106.35],
radius=1000, color='red',
fill_opacity=0.5).add_to(world_map)
Chorpleth Create a choropleth map based on a GeoJSON file and a specified data column. folium.Choropleth(geo_data='path/to/geojson_file',
data=df, columns=['region', 'value_column'],
key_on='feature.properties.id', fill_color='YlGnBu',
fill_opacity=0.7, line_opacity=0.2,
legend_name='Legend').add_to(map)
world_map.choropleth(geo_data=world_geo,
data=df_can, columns=['Country', 'Total'],
key_on='feature.properties.name', fill_color='YlOrRd',
fill_opacity=0.7,line_opacity=0.2,
legend_name='Immigration to Canada')
PyWaffle
Waffle Create a waffle chart based on values and categories. plt.figure(FigureClass = Waffle,rows = 20, columns = 30, values = values)

waffle_chart = waffle.Waffle(values=[value1, value2, ...],
rows=n, columns=n)
plt.figure(FigureClass = Waffle,rows = 20, columns = 30,
values = df_dsn['Total'], cmap_name = 'tab20',
legend = {'labels': label,'loc': 'lower left',
'bbox_to_anchor':(0,-0.1),'ncol': 3})
Legend Add a legend to the waffle chart. waffle_chart.legend(loc='upper left', bbox_to_anchor=(1, 1))
Title Add a title to the waffle chart. waffle_chart.set_title('Waffle Chart Title')
Labels Add labels to the waffle chart. waffle_chart.set_labels(['Label 1', 'Label 2', ...])
WordCloud
WordCloud Create a word cloud object based on text data. wordcloud = WordCloud().generate(text_data) alice_wc = WordCloud(background_color='white', max_words=2000, mask=alice_mask, stopwords=stopwords)
alice_wc.generate(alice_novel)
plt.imshow(alice_wc, interpolation='bilinear')
Generate Generate the word cloud based on the text data. wordcloud.generate(text_data)
Display Display the word cloud using matplotlib or other plotting libraries. plt.imshow(wordcloud, interpolation='bilinear')
Options Set various options for the word cloud, such as font, colors, mask, and stopwords. wordcloud = WordCloud(font_path='path/to/font_file',
background_color='white',
colormap='Blues', mask=mask_image,
stopwords=stopwords).generate(text_data)
Seaborn
barplot Create a bar plot to visualize the relationship between a categorical variable and a numeric variable. sns.barplot(x='x_variable', y='y_variable', data=dataframe) sns.barplot(x='Continent', y='Total', data=df_can1)
countplot Create a count plot to display the frequency of each category in a categorical variable. sns.countplot(x='category', data=dataframe) sns.countplot(x='Continent', data=df_can)
regplot Create a scatter plot with a linear regression line to visualize the relationship between two numeric variables. sns.regplot(x='x_variable',
y='y_variable', data=dataframe)
sns.regplot(x='year', y='total', data=df_tot)


Author(s)

Dr. Pooja

Changelog

Date Version Changed by Change Description
2023-06-18 0.1 Dr. Pooja Initial version created
ModuleFolder='C:\\Users\\Gamaliel\\Documents\\G\\ADD\\IBM_DS\\Visualization\\M04\\HTMLs\\'
os.chdir(ModuleFolder)
for file in os.listdir(ModuleFolder):
    #if file.lower().endswith('HTMLs.html'):
        #continue
    if file.lower().endswith('.html'):
        link=file
        #print(link)  
        display(HTML(ModuleFolder+link))
    elif file.lower().endswith('.htm'):
        link=file
        #print(link)  
        display(HTML(ModuleFolder+link))
    else:
        continue
    
os.chdir(NBdir)
try:
    !jupyter nbconvert Vis_HTMLs.ipynb --to html --template pj
except Exception as e:
    print('HTML not stored')
import shutil
import os
import shutil
FromFld=NBdir
Tofld='C:\\Users\\Gamaliel\\Documents\\G\\ADD\\IBM_DS\\IBM_DS_Jupyter_Tasks\\Python4DataScience\\'
HTML_Notes='Vis_HTMLs.html'
Jupyter_Notes='Vis_HTMLs.ipynb'
try:
    if os.path.isfile(Tofld+'/'+HTML_Notes):
        os.remove(Tofld+'/'+HTML_Notes)
        print(HTML_Notes, 'deleted in', Tofld)
        shutil.move(os.path.join(FromFld,HTML_Notes),os.path.join(Tofld,HTML_Notes))
        print(HTML_Notes, 'replaced in', Tofld)
    else:
        shutil.move(os.path.join(FromFld,HTML_Notes),os.path.join(Tofld,HTML_Notes))
        print(HTML_Notes, 'written in', Tofld)
except Exception as e:
    print('HTML not moved')

    # NB

try:
    if os.path.isfile(Tofld+'/'+Jupyter_Notes):
        os.remove(Tofld+'/'+Jupyter_Notes)
        print(Jupyter_Notes, 'deleted in', Tofld)
        shutil.copy(os.path.join(FromFld,Jupyter_Notes),os.path.join(Tofld,Jupyter_Notes))
        print(Jupyter_Notes, 'copied in', Tofld)
    else:
        shutil.copy(os.path.join(FromFld,Jupyter_Notes),os.path.join(Tofld,Jupyter_Notes))
        print(Jupyter_Notes, 'copied in', Tofld)
except Exception as e:
    print('NB not moved')